def bb_name_ming(wanfa_name):
    # print(wanfa_name)
    global eventbase
    if "大小" in wanfa_name or "总得分" in wanfa_name:
        if "大小" in wanfa_name and "全场" in wanfa_name:
            if "角球" in wanfa_name:
                if "主" in wanfa_name:
                    eventbase = "全主角大小"
                elif "客" in wanfa_name:
                    eventbase = "全客角大小"
                else:
                    eventbase = "全场角球大小"
            elif "黄牌" in wanfa_name:
                if "主" in wanfa_name:
                    eventbase = "全主黄牌大小"
                elif "客" in wanfa_name:
                    eventbase = "全客黄牌大小"
                else:
                    eventbase = "全场黄牌大小"
            elif "红牌" in wanfa_name:
                if "主" in wanfa_name:
                    eventbase = "全主红牌大小"
                elif "客" in wanfa_name:
                    eventbase = "全客红牌大小"
                else:
                    eventbase = "全场红牌大小"
            else:
                if "主" in wanfa_name:
                    eventbase = "全场主大小"
                elif "客" in wanfa_name:
                    eventbase = "全场客大小"
                else:
                    eventbase = "全场大小"
            return eventbase
        elif ("半场" in wanfa_name and "大小" in wanfa_name) or "总得分" in wanfa_name:
            if "角球" in wanfa_name:
                if "第1半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主角大小"
                    elif "客" in wanfa_name:
                        eventbase = "上半客角大小"
                    else:
                        eventbase = "上半角球大小"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主角大小"
                    elif "客" in wanfa_name:
                        eventbase = "下半客角大小"
                    else:
                        eventbase = "下半角球大小"
            elif "黄牌" in wanfa_name:
                if "第1半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主黄牌大小"
                    elif "客" in wanfa_name:
                        eventbase = "上半客黄牌大小"
                    else:
                        eventbase = "上半黄牌大小"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主黄牌大小"
                    elif "客" in wanfa_name:
                        eventbase = "下半客黄牌大小"
                    else:
                        eventbase = "下半黄牌大小"
            else:
                if "第1半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主大小"
                    elif "客" in wanfa_name:
                        eventbase = "上半客大小"
                    else:
                        eventbase = "上半场大小"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主大小"
                    elif "客" in wanfa_name:
                        eventbase = "下半客大小"
                    else:
                        eventbase = "下半场大小"
            return eventbase
        elif "亚洲盘大小" in wanfa_name:
            if "主" in wanfa_name:
                eventbase = "全场主大小"
            elif "客" in wanfa_name:
                eventbase = "全场客大小"
            # print(eventbase)
            return eventbase
        elif '罚牌积分' in wanfa_name:
            eventbase = "全场黄牌大小"
            return eventbase
        else:
            # print(wanfa_name)
            pass
    elif "让分" in wanfa_name or "让球" in wanfa_name:
        if "全场" in wanfa_name:
            if "角" in wanfa_name:
                if "主" in wanfa_name:
                    eventbase = "全场主角让"
                elif "客" in wanfa_name:
                    eventbase = "全场客角让"
                else:
                    eventbase = "全场角让"
            elif "黄牌" in wanfa_name:
                if "主" in wanfa_name:
                    eventbase = "全场主黄牌让"
                elif "客" in wanfa_name:
                    eventbase = "全场客黄牌让"
                else:
                    eventbase = "全场黄牌让"
            else:
                if "主" in wanfa_name:
                    eventbase = "全场主让"
                elif "客" in wanfa_name:
                    eventbase = "全场客让"
                else:
                    eventbase = "全场让"
            return eventbase
        elif "半场" in wanfa_name:
            if "角" in wanfa_name:
                if "第1 半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主角让"
                    elif "客" in wanfa_name:
                        eventbase = "上半客角让"
                    else:
                        eventbase = "上半角球让"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主角让"
                    elif "客" in wanfa_name:
                        eventbase = "下半客角让"
                    else:
                        eventbase = "下半角球让"
            elif "黄牌" in wanfa_name:
                if "第1 半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主黄牌让"
                    elif "客" in wanfa_name:
                        eventbase = "上半客黄牌让"
                    else:
                        eventbase = "上半黄牌让"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主黄牌让"
                    elif "客" in wanfa_name:
                        eventbase = "下半客黄牌让"
                    else:
                        eventbase = "下半黄牌让"
            else:
                if "第1 半场" in wanfa_name or "上" in wanfa_name:
                    if "主" in wanfa_name:
                        eventbase = "上半主让"
                    elif "客" in wanfa_name:
                        eventbase = "上半客让"
                    else:
                        eventbase = "上半场让"
                else:
                    if "主" in wanfa_name:
                        eventbase = "下半主让"
                    elif "客" in wanfa_name:
                        eventbase = "下半客让"
                    else:
                        eventbase = "下半场让"

            return eventbase

    else:
        # print(wanfa_name)
        return wanfa_name


def num_data(event_base):
    if "-" not in str(event_base):
        if ".25" in str(event_base):
            eventbase = event_base
            event_base = str(int(eventbase - float(0.25))) + "/" + str(eventbase + float(0.25))
            # print(event_base,eventbase)

        elif ".75" in str(event_base):
            eventbase = event_base
            event_base = str(eventbase - float(0.25)) + "/" + str(int(eventbase + float(0.25)))
            # print(event_base,eventbase)

        return event_base
    else:
        # print(event_base)
        if ".25" in str(event_base):
            eventbase = event_base
            if "0.25" in str(event_base):
                event_base = "-" + str(int(eventbase + float(0.25))) + "/" + str(-eventbase + float(0.25))
            else:
                event_base = str(int(eventbase + float(0.25))) + "/" + str(-eventbase + float(0.25))

        elif ".75" in str(event_base):
            eventbase = event_base
            event_base = str(eventbase + float(0.25)) + "/" + str(int(-eventbase + float(0.25)))

        return event_base


def fb_name_ming(leibie, guojia1, guojia2):

    global nm_num1
    if "分钟" not in leibie and '加时' not in leibie:
        if "大" in leibie and "角球" not in leibie:
            if "半场" in leibie:
                if "上半场" in leibie:
                    if "罚牌" in leibie:
                        if guojia1 in leibie:
                            nm_num1 = "上半主黄牌大小"
                        elif guojia2 in leibie:
                            nm_num1 = "上半客黄牌大小"
                        else:
                            nm_num1 = "上半黄牌大小"
                    else:
                        if guojia1 in leibie:
                            nm_num1 = "上半主大小"
                        elif guojia2 in leibie:
                            nm_num1 = "上半客大小"
                        else:
                            nm_num1 = "上半场大小"
                else:
                    if "罚牌" in leibie:
                        if guojia1 in leibie:
                            nm_num1 = "下半主黄牌大小"
                        elif guojia2 in leibie:
                            nm_num1 = "下半客黄牌大小"
                        else:
                            nm_num1 = "下半黄牌大小"
                    else:
                        if guojia1 in leibie:
                            nm_num1 = "下半主大小"
                        elif guojia2 in leibie:
                            nm_num1 = "下半客大小"
                        else:
                            nm_num1 = "下半场大小"
            else:
                if "罚牌" in leibie:
                    if guojia1 in leibie:
                        nm_num1 = "全场主黄牌大小"
                    elif guojia2 in leibie:
                        nm_num1 = "全场客黄牌大小"
                    else:
                        nm_num1 = "全场黄牌大小"
                else:
                    if guojia1 == leibie[:-8]:
                        # print(guojia1,"***",leibie[:-8],'**',guojia1==leibie[:-8])
                        # print()
                        nm_num1 = "全场主大小"
                        # print(guojia1, "--", leibie)
                    elif guojia2 in leibie:
                        nm_num1 = "全场客大小"
                        # print(guojia2,"**",leibie)
                    elif leibie=='大/小':
                        # print(leibie)
                        nm_num1 = "全场大小"
            return nm_num1

        elif "让" in leibie and "角" not in leibie:
            if "半场" in leibie:
                if "上半场" in leibie:
                    if "罚牌" in leibie:
                        if guojia1 in leibie:
                            nm_num1 = "上半主黄牌让"
                        elif guojia2 in leibie:
                            nm_num1 = "上半客黄牌让"
                        else:
                            nm_num1 = "上半黄牌让"
                    else:
                        if guojia1 in leibie:
                            nm_num1 = "上半主让"
                        elif guojia2 in leibie:
                            nm_num1 = "上半客让"
                        else:
                            nm_num1 = "上半场让"
                else:
                    if "罚牌" in leibie:
                        if guojia1 in leibie:
                            nm_num1 = "下半主黄牌让"
                        elif guojia2 in leibie:
                            nm_num1 = "下半客黄牌让"
                        else:
                            nm_num1 = "下半黄牌让"
                    else:
                        if guojia1 in leibie:
                            nm_num1 = "下半主让"
                        elif guojia2 in leibie:
                            nm_num1 = "下半客让"
                        else:
                            nm_num1 = "下半场让"
            # elif "角" in leibie:
            #     if "上半" in leibie:
            #         if guojia1 in leibie:
            #             nm_num1 = "上半场主角让"
            #         elif guojia2 in leibie:
            #             nm_num1 = "上半场客角让"
            #         else:
            #             nm_num1 = "上半场角让"
            #     elif "下半" in leibie:
            #         if guojia1 in leibie:
            #             nm_num1 = "下半场主角让"
            #         elif guojia2 in leibie:
            #             nm_num1 = "下半场客角让"
            #         else:
            #             nm_num1 = "下半场角让"
            #     else:
            #         if guojia1 in leibie:
            #             nm_num1 = "全场主角让"
            #         elif guojia2 in leibie:
            #             nm_num1 = "全场客角让"
            #         else:
            #             nm_num1 = "全场角让"
            else:
                if "罚牌" in leibie:
                    if guojia1 in leibie:
                        nm_num1 = "全场主黄牌让"
                    elif guojia2 in leibie:
                        nm_num1 = "全场客黄牌让"
                    else:
                        nm_num1 = "全场黄牌让"
                else:
                    if guojia1 in leibie:
                        nm_num1 = "全场主让"
                    elif guojia2 in leibie:
                        nm_num1 = "全场客让"
                    else:
                        nm_num1 = "全场让"
            return nm_num1

        elif "角球" in leibie and "开始" not in leibie:
            if "半场" in leibie and "让" not in leibie:
                if "上" in leibie:
                    if guojia1 in leibie:
                        nm_num1 = "上半主角大小"
                    elif guojia2 in leibie:
                        nm_num1 = "上半客角大小"
                    else:
                        nm_num1 = "上半角球大小"
                else:
                    if guojia1 in leibie:
                        nm_num1 = "下半主角大小"
                    elif guojia2 in leibie:
                        nm_num1 = "下半客角大小"
                    else:
                        nm_num1 = "下半角球大小"
            elif "让" in leibie:
                if "上半" in leibie:
                    if guojia1 in leibie:
                        nm_num1 = "上半场主角让"
                    elif guojia2 in leibie:
                        nm_num1 = "上半场客角让"
                    else:
                        nm_num1 = "上半场角让"
                elif "下半" in leibie:
                    if guojia1 in leibie:
                        nm_num1 = "下半场主角让"
                    elif guojia2 in leibie:
                        nm_num1 = "下半场客角让"
                    else:
                        nm_num1 = "下半场角让"
                else:
                    if guojia1 in leibie:
                        nm_num1 = "全场主角让"
                    elif guojia2 in leibie:
                        nm_num1 = "全场客角让"
                    else:
                        nm_num1 = "全场角让"
            else:
                if guojia1 in leibie:
                    nm_num1 = "全主角大小"
                elif guojia2 in leibie:
                    nm_num1 = "全客角大小"
                else:
                    nm_num1 = "全场角球大小"

            return nm_num1

        else:
            return leibie
    elif '加时' in leibie:
        if "大" in leibie:
            if "上半场" in leibie:
                if guojia1 in leibie:
                    nm_num1 = "上半主加时大小"
                elif guojia2 in leibie:
                    nm_num1 = "上半客加时大小"
                else:
                    nm_num1 = "上半场加时大小"
                # print(leibie,"------",nm_num1)
            else:
                if guojia1 in leibie:
                    nm_num1 = "全场主加时大小"
                elif guojia2 in leibie:
                    nm_num1 = "全场客加时大小"
                else:
                    nm_num1 = "全场加时大小"
                # print(leibie, "------", nm_num1)
                # return

        elif "让" in leibie:
            if "上半场" in leibie:
                if guojia1 in leibie:
                    nm_num1 = "上半主加时让"
                elif guojia2 in leibie:
                    nm_num1 = "上半客加时让"
                else:
                    nm_num1 = "上半场加时让"
                # print(leibie, "------", nm_num1)
            else:
                if guojia1 in leibie:
                    nm_num1 = "全场主加时让"
                elif guojia2 in leibie:
                    nm_num1 = "全场客加时让"
                else:
                    nm_num1 = "全场加时让"
                # print(leibie, "------", nm_num1)

        return nm_num1

def od(od_data, zhu, ke, n):
        ran_all = []
        if n == 0:
            ran_name = '全场让'
            da_name = '全场大小'
        elif n == 1:
            ran_name = '上半场让'
            da_name = '上半场大小'
        elif n == 2:
            ran_name = '全场角让'
            da_name = '全场角球大小'
        elif n == 3:
            ran_name = '上半场角让'
            da_name = '上半角球大小'
        try:
            od_ran = od_data['8']
            for ran in od_ran:
                hdp = od_ran[ran]["hdp"]  # 盘口
                fav = od_ran[ran]["fav"]  # 定 + -
                oddsa = od_ran[ran]["oddsa"]
                oddsb = od_ran[ran]["oddsb"]
                if fav == 'a':
                    ran_od = ran_name, zhu, '-' + hdp, oddsa, ke, hdp, oddsb
                else:
                    ran_od = ran_name, zhu, hdp, oddsa, ke, '-' + hdp, oddsb
                ran_all.append(ran_od)
        except Exception as e:
            # print('od_ran = od_data[8]', e)
            pass
        try:
            od_da = od_data['9']
            for da in od_da:
                hdp = od_da[da]["hdp"]  # 盘口
                oddsa = od_da[da]["oddsa"]
                oddsb = od_da[da]["oddsb"]
                ran_od = da_name, '大', hdp, oddsa, '小', hdp, oddsb
                ran_all.append(ran_od)
        except Exception as e:
            # print('od_ran = od_data[9]', e)
            pass
        return ran_all


def bti_name(ty_name,duiwu_name):
    if "让" in ty_name:
        if "上" in ty_name:
            ty_name = "上半场让"
        elif "下" in ty_name:
            ty_name = "下半场让"
        else:
            ty_name = "全场让"
    elif "大" in ty_name and "角" not in ty_name:
        if "上" in ty_name:
            if duiwu_name["Home"] in ty_name:
                ty_name = "上主半大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "上客半大小"
            else:
                ty_name = "上半场大小"
        elif "下" in ty_name:
            if duiwu_name["Home"] in ty_name:
                ty_name = "下主半大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "下客半大小"
            else:
                ty_name = "下半场大小"
        else:
            if duiwu_name["Home"] in ty_name:
                ty_name = "全场主大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "全场客大小"
            else:
                ty_name = "全场大小"
    elif "角" in ty_name:
        if "上" in ty_name:
            if duiwu_name["Home"] in ty_name:
                ty_name = "上半主角大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "上半客角大小"
            else:
                ty_name = "上半角球大小"
        elif "下" in ty_name:
            if duiwu_name["Home"] in ty_name:
                ty_name = "下半主角大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "下半客角大小"
            else:
                ty_name = "下半角球大小"
        else:
            if duiwu_name["Home"] in ty_name:
                ty_name = "全主角大小"
            elif duiwu_name["Away"] in ty_name:
                ty_name = "全客角大小"
            else:
                ty_name = "全场角球大小"
    return ty_name